package com.wyj.code.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.wyj.code.entity.dto.CodeDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * TODO: 验证码持久化对象
 *
 * @author wuyijie
 * @date 2022/2/10 5:35 PM
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "t_code")
public class CodePO implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(value = "ID", type = IdType.ASSIGN_UUID)
    private String id;
    @TableField(value = "CODE")
    private String code;
    @TableField(value = "IDENTIFICATION")
    private String identification;
    @TableField(value = "DEADLINE")
    private LocalDateTime deadline;

    public CodeDTO convert() {
        final CodeDTO codeDTO = new CodeDTO();
        codeDTO.setCode(this.getCode());
        codeDTO.setIdentification(this.getIdentification());
        codeDTO.setDeadline(this.deadline);
        return codeDTO;
    }
}
